
        <html>
			<head>
			     <title>OSSEC 学习教程一 - 只抽红梅</title>
				 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
			</head>
			<body>
				<h1>原文地址:<a href="http://drops.wooyun.org/tips/636">http://drops.wooyun.org/tips/636</a></h1>
				
      <p>
        <h2>简介</h2>

<hr />

<p>写在前面的话，网上能够找到一些关于ossec方面的资料，虽然很少，但是总比没有强，不过在实际的使用过程中还是会碰到许多稀奇古怪的问题。整理整理我的使用过程，就当做一篇笔记吧。</p>

<p>PS：本文填了很多坑。</p>

<p>OSSEC是一款开源的基于主机的入侵检测系统，可以简称为HIDS。它具备日志分析，文件完整性检查，策略监控，rootkit检测，实时报警以及联动响应等功能。它支持多种操作系统：Linux、Windows、MacOS、Solaris、HP-UX、AIX。属于企业安全之利器。</p>

<!--more-->

<p>详细的介绍和文档可以参考官网网站：</p>

<p><a href="http://www.ossec.net/">http://www.ossec.net/</a></p>

<h2>环境</h2>

<hr />

<p>本文中的环境极其简单，两台CentOS 6.4虚拟机。</p>

<p>服务端</p>

<pre><code>计算机名：ossec-server
IP地址：192.168.100.103
</code></pre>

<p>客户端</p>

<pre><code>计算机名：ossec-agent
IP地址：192.168.100.104
</code></pre>

<h2>准备</h2>

<hr />

<p>我们以一个全新的CentOS 6.2为基础的操作系统为例实际讲述如何进行安装。</p>

<p>首先我们安装需要用到的关联库和软件，由于我们最终是需要把日志导入到MySQL中进行分析，以及需要通过web程序对报警结果进行展示，同时需要把本机当做SMTP，所以需要在本机安装MySQL、Apache和sendmail服务。在当前的终端中执行如下命令：</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="80f2efeff4c0eff3f3e5e3adf3e5f2f6e5f2">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# yum install wget gcc make mysql mysql-server mysql-devel httpd php php-mysql sendmail
</code></pre>

<p>启动httpd、mysql、sendmail服务</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="a5d7cacad1e5cad6d6c0c688d6c0d7d3c0d7">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# /etc/init.d/httpd start
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="62100d0d16220d111107014f110710140710">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# /etc/init.d/mysqld start
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="7b0914140f3b1408081e1856081e090d1e09">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# /etc/init.d/sendmail start
</code></pre>

<p>下面创建数据库以方便我们下面的安装配置，连接到本机的MySQL，然后执行如下命令：</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="1a6875756e5a7569697f7937697f686c7f68">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# mysql -uroot -p
mysql&gt; create database ossec;
mysql&gt; grant INSERT,SELECT,UPDATE,CREATE,DELETE,EXECUTE on ossec.* to <a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="711e02021412311d1e12101d191e0205">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script>;
mysql&gt; set password for <a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="335c40405650735f5c50525f5b5c4047">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script>=PASSWORD('ossec');
mysql&gt; flush privileges;
mysql&gt; exit
</code></pre>

<p>大概的环境已经准备的差不多了，下面就进入到实际安装过程。</p>

<h2>安装OSSEC服务端</h2>

<hr />

<p>首先通过官网的链接下载当前的最新稳定版本 2.7 的服务端包，同时解压。</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="bfcdd0d0cbffd0ccccdadc92ccdacdc9dacd">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# wget http://www.ossec.net/files/ossec-hids-2.7.tar.gz
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="2f5d40405b6f405c5c4a4c025c4a5d594a5d">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# tar zxf ossec-hids-2.7.tar.gz
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="2c5e4343586c435f5f494f015f495e5a495e">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# cd ossec-hids-2.7
</code></pre>

<p>为了使OSSEC支持MySQL，需要在安装前执行make setdb命令，如下</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="4e3c21213a0e213d3d2b2d633d2b3c382b3c">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# cd src; make setdb; cd ..
</code></pre>

<p>看到如下的信息说明可以正常支持MySQL：</p>

<pre><code>Info: Compiled with MySQL support.
</code></pre>

<p>下面进入安装步骤，执行install.sh脚本，同时按照下面的信息进行填写，红色部门是我们需要输入的，其余部分按回车继续即可：</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="3a4855554e7a5549495f5917495f484c5f48">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ossec-hids-2.7]# ./install.sh

  ** Para instalação em português, escolha [br].
  ** 要使用中文进行安装, 请选择 [cn].
  ** Fur eine deutsche Installation wohlen Sie [de].
  ** Για εγκατάσταση στα Ελληνικά, επιλέξτε [el].
  ** For installation in English, choose [en].
  ** Para instalar en Español , eliga [es].
  ** Pour une installation en français, choisissez [fr]
  ** A Magyar nyelvű telepítéshez válassza [hu].
  ** Per l'installazione in Italiano, scegli [it].
  ** 日本語でインストールします．選択して下さい．[jp].
  ** Voor installatie in het Nederlands, kies [nl].
  ** Aby instalować w języku Polskim, wybierz [pl][/pl].
  ** Для инструкций по установке на русском ,введите [ru].
  ** Za instalaciju na srpskom, izaberi [sr].
  ** Türkçe kurulum için seçin [tr].
  (en/br/cn/de/el/es/fr/hu/it/jp/nl/pl/ru/sr/tr) [en]: cn
 OSSEC HIDS v2.7 安装脚本 - http://www.ossec.net
</code></pre>

<p>您将开始 OSSEC HIDS 的安装.
 请确认在您的机器上已经正确安装了 C 编译器.
 如果您有任何疑问或建议,请给 <a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="f591969c91b59a86869096db9b9081">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> (或 <a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="badedbd4d3dfd694d9d3defaddd7dbd3d694d9d5d7">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script>) 发邮件.</p>

<ul>
<li>系统类型: Linux ossec 2.6.32-358.el6.x86_64</li>
<li>用户: root</li>
<li><p>主机: ossec</p>

<p>-- 按 ENTER 继续或 Ctrl-C 退出. --</p></li>
</ul>

<p>1- 您希望哪一种安装 (server, agent, local or help)? <strong>server</strong></p>

<ul>
<li>选择了 Server 类型的安装.</li>
</ul>

<p>2- 正在初始化安装环境.</p>

<ul>
<li><p>请选择 OSSEC HIDS 的安装路径 [/var/ossec]: <strong>/opt/ossec</strong></p>

<ul>
<li>OSSEC HIDS 将安装在  /opt/ossec .</li>
</ul></li>
</ul>

<p>3- 正在配置 OSSEC HIDS.</p>

<p>3.1- 您希望收到e-mail告警吗? (y/n) [y]: 
   - 请输入您的 e-mail 地址? <strong><a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="432c303026206d3726303703242e222a2f6d202c2e">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script></strong></p>

<ul>
<li>我们找到您的 SMTP 服务器为: alt1.gmail-smtp-in.l.google.com.</li>
<li><p>您希望使用它吗? (y/n) [y]: n</p></li>
<li><p>请输入您的 SMTP 服务器IP或主机名 ? <strong>127.0.0.1</strong></p>

<p>3.2- 您希望运行系统完整性检测模块吗? (y/n) [y]:</p></li>
<li><p>系统完整性检测模块将被部署.</p>

<p>3.3- 您希望运行 rootkit检测吗? (y/n) [y]:</p></li>
<li><p>rootkit检测将被部署.</p>

<p>3.4- 关联响应允许您在分析已接收事件的基础上执行一个
   已定义的命令.
   例如,你可以阻止某个IP地址的访问或禁止某个用户的访问权限.
   更多的信息,您可以访问:
   http://www.ossec.net/en/manual.html#active-response</p></li>
<li><p>您希望开启联动(active response)功能吗? (y/n) [y]:</p>

<ul>
<li>关联响应已开启</li>
</ul></li>
<li><p>默认情况下, 我们开启了主机拒绝和防火墙拒绝两种响应.
 第一种情况将添加一个主机到 /etc/hosts.deny.
 第二种情况将在iptables(linux)或ipfilter(Solaris,
 FreeBSD 或 NetBSD）中拒绝该主机的访问.</p></li>
<li><p>该功能可以用以阻止 SSHD 暴力攻击, 端口扫描和其他
 一些形式的攻击. 同样你也可以将他们添加到其他地方,
 例如将他们添加为 snort 的事件.</p></li>
<li><p>您希望开启防火墙联动(firewall-drop)功能吗? (y/n) [y]:</p>

<ul>
<li>防火墙联动(firewall-drop)当事件级别 >= 6 时被启动</li>
</ul></li>
<li><p>联动功能默认的白名单是:</p>

<ul>
<li>8.8.8.8</li>
</ul></li>
<li><p>您希望添加更多的IP到白名单吗? (y/n)? [n]: y</p></li>
<li><p>请输入IP (用空格进行分隔): <strong>192.168.100.103</strong></p>

<p>3.5- 您希望接收远程机器syslog吗 (port 514 udp)? (y/n) [y]:</p></li>
<li><p>远程机器syslog将被接收.</p>

<p>3.6- 设置配置文件以分析一下日志:
-- /var/log/messages
-- /var/log/secure
-- /var/log/maillog</p>

<p>-如果你希望监控其他文件, 只需要在配置文件ossec.conf中
添加新的一项.
任何关于配置的疑问您都可以在 http://www.ossec.net 找到答案.</p>

<p>--- 按 ENTER 以继续 ---</p></li>
</ul>

<p>5- 正在安装系统
 - 正在运行Makefile
INFO: Little endian set.
…………省略编译输出…………</p>

<ul>
<li><p>系统类型是  Redhat Linux.</p>

<ul>
<li><p>修改启动脚本使 OSSEC HIDS 在系统启动时自动运行</p></li>
<li><p>已正确完成系统配置.</p></li>
<li><p>要启动 OSSEC HIDS:
        /opt/ossec/bin/ossec-control start</p></li>
<li><p>要停止 OSSEC HIDS:
        /opt/ossec/bin/ossec-control stop</p></li>
<li><p>要查看或修改系统配置,请编辑  /opt/ossec/etc/ossec.conf</p></li>
</ul>

<p>感谢使用 OSSEC HIDS.
如果您有任何疑问,建议或您找到任何bug,
<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="c1296e7628415b297e46224141a2aeafb5a0a2b581aeb2b2a4a2efafa4b5">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> 或邮件列表 <a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="e38c90908680ce8f8a9097a38c90908680cd8d8697">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> 联系我们.<br />
( http://www.ossec.net/en/mailing_lists.html ).</p>

<p>您可以在　http://www.ossec.net 获得更多信息</p>

<p>--- 请按　ENTER 结束安装 (下面可能有更多信息). ---</p></li>
</ul>

<p>直到碰到上面内容，说明安装完成。</p>

<h2>OSSEC服务端配置</h2>

<hr />

<p>上面只是安装好了OSSEC服务端，下面则是为了配置服务端，使其工作正常。执行下面命令启用数据库支持：</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="66140909122609151503054b150314100314">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ossec-hids-2.7]# /opt/ossec/bin/ossec-control enable database
</code></pre>

<p>然后导入MySQL表结构到MySQL中：</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="b0c2dfdfc4f0dfc3c3d5d39dc3d5c2c6d5c2">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ossec-hids-2.7]# mysql -uossec -p ossec &lt; ./src/os_dbd/mysql.schema
</code></pre>

<p>修改部分配置文件的权限，否则会启动服务失败：</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="6a1805051e2a0519190f0947190f181c0f18">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ossec-hids-2.7]# chmod u+w /opt/ossec/etc/ossec.conf
</code></pre>

<p>然后我们编辑ossec.conf文件，在ossec_config中添加MySQL配置：</p>

<pre><code>&lt;ossec_config&gt;
    &lt;database_output&gt;
        &lt;hostname&gt;192.168.100.103&lt;/hostname&gt;
        &lt;username&gt;ossec&lt;/username&gt;
        &lt;password&gt;ossec&lt;/password&gt;
        &lt;database&gt;ossec&lt;/database&gt;
        &lt;type&gt;mysql&lt;/type&gt;
    &lt;/database_output&gt;
&lt;/ossec_config&gt;
</code></pre>

<p>由于我们在前面的安装过程中支持接受远程机器的syslog，所以我们还需要对ossec.conf文件中的syslog部分进行配置，修改ossec.conf文件，按照下面的内容进行修改，把我们网段可以全添加进去：</p>

<pre><code>  &lt;remote&gt;
    &lt;connection&gt;syslog&lt;/connection&gt;
    &lt;allowed-ips&gt;192.168.0.0/16&lt;/allowed-ips&gt;
  &lt;/remote&gt;
</code></pre>

<p>在实际的实验过程中启动ossec服务端必须先添加一个客户端，否则直接启动服务端是会失败的，通过如下命令查看日志会发现如下错误：</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="0d7f6262794d627e7e686e207e687f7b687f">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> logs]# cat /opt/ossec/logs/ossec.log

2013/09/23 23:43:15 ossec-analysisd(1210): ERROR: Queue '/queue/alerts/ar' not accessible: 'Connection refused'.
2013/09/23 23:43:15 ossec-analysisd(1301): ERROR: Unable to connect to active response queue.
</code></pre>

<p>在服务器上添加客户端，执行如下命令，按照提示进行输入，红色部分是我们输入的：</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="47352828330728343422246a342235312235">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> logs]# /opt/ossec/bin/manage_agents

   ****************************************
   * OSSEC HIDS v2.7 Agent manager.     *
   * The following options are available: *
   ****************************************
      (A)dd an agent (A).
      (E)xtract key for an agent (E).
      (L)ist already added agents (L).
      (R)emove an agent (R).
      (Q)uit.
</code></pre>

<p>Choose your action: A,E,L,R or Q: <strong>A</strong></p>

<ul>
<li><p>Adding a new agent (use '\q' to return to the main menu).
 Please provide the following:</p>

<ul>
<li>A name for the new agent: <strong>ossec-agent</strong></li>
<li>The IP Address of the new agent: <strong>192.168.100.104</strong></li>
<li>An ID for the new agent[001]: 
Agent information:
ID:001
Name:ossec-agent
IP Address:192.168.100.104</li>
</ul>

<p>Confirm adding it?(y/n): <strong>y</strong>
Agent added.</p></li>
</ul>

<p>然后程序会重新进入到第一次的界面，如下，我们导出刚才添加的那个agent的key，用于后面的客户端连接到服务端：</p>

<pre><code>   ****************************************
   * OSSEC HIDS v2.7 Agent manager.     *
   * The following options are available: *
   ****************************************
      (A)dd an agent (A).
      (E)xtract key for an agent (E).
      (L)ist already added agents (L).
      (R)emove an agent (R).
      (Q)uit.
</code></pre>

<p>Choose your action: A,E,L,R or Q: <strong>E</strong></p>

<p>Available agents: 
      ID: 001, Name: ossec-agent, IP: 192.168.100.104
   Provide the ID of the agent to extract the key (or '\q' to quit): <strong>001</strong></p>

<p>Agent key information for '001' is: 
   MDAxIG9zc2VjLWFnZW50IDE5Mi4xNjguMTAwLjEwNCAzZWJmZWMzZmRlYzE2ODgzZmEyMzc0NWI5MWMyZDlmNmIyNDViZDMxNjBkZGRiM2FlMTk4NDA3ODNiNDFhYzYz</p>

<p>** Press ENTER to return to the main menu.</p>

<p>到现在就可以启动我们的ossec服务端了。</p>

<pre><code># /opt/ossec/bin/ossec-control start
</code></pre>

<p>或者执行</p>

<pre><code># /etc/init.d/ossec start
</code></pre>

<p><br></p>

<h2>安装OSSEC客户端</h2>

<hr />

<p>由于我们本身客户端也是Linux服务器，而ossec的服务端和客户端是同一个安装包，所以在客户端上下载安装包，并且解压安装，如下。</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="51233e3e25113e222234327c223423273423">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# wget http://www.ossec.net/files/ossec-hids-2.7.tar.gz
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="ec9e838398ac839f9f898fc19f899e9a899e">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# tar zxf ossec-hids-2.7.tar.gz
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="02706d6d76426d717167612f716770746770">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# cd ossec-hids-2.7
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="85f7eaeaf1c5eaf6f6e0e6a8f6e0f7f3e0f7">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# ./install.sh 
</code></pre>

<p>** Para instalação em português, escolha [br].
  ** 要使用中文进行安装, 请选择 [cn].
  ** Fur eine deutsche Installation wohlen Sie [de].
  ** Για εγκατάσταση στα Ελληνικά, επιλέξτε [el].
  ** For installation in English, choose [en].
  ** Para instalar en Español , eliga [es].
  ** Pour une installation en français, choisissez [fr]
  ** A Magyar nyelvű telepítéshez válassza [hu].
  ** Per l'installazione in Italiano, scegli [it].
  ** 日本語でインストールします．選択して下さい．[jp].
  ** Voor installatie in het Nederlands, kies [nl].
  ** Aby instalować w języku Polskim, wybierz [pl][/pl].
  ** Для инструкций по установке на русском ,введите [ru].
  ** Za instalaciju na srpskom, izaberi [sr].
  ** Türkçe kurulum için seçin [tr].
  (en/br/cn/de/el/es/fr/hu/it/jp/nl/pl/ru/sr/tr) [en]: <strong>cn</strong>
 OSSEC HIDS v2.7 安装脚本 - http://www.ossec.net</p>

<p>您将开始 OSSEC HIDS 的安装.
 请确认在您的机器上已经正确安装了 C 编译器.
 如果您有任何疑问或建议,请给 <a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="7b1f18121f3b1408081e1855151e0f">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> (或 <a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="fb9f9a95929e97d598929fbb9c969a9297d5989496">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script>) 发邮件.</p>

<ul>
<li>系统类型: Linux ossec-agent 2.6.18-164.el5</li>
<li>用户: root</li>
<li><p>主机: ossec-agent</p>

<p>-- 按 ENTER 继续或 Ctrl-C 退出. --</p></li>
</ul>

<p>1- 您希望哪一种安装 (server, agent, local or help)? <strong>agent</strong></p>

<ul>
<li>选择了 Agent(client) 类型的安装.</li>
</ul>

<p>2- 正在初始化安装环境.</p>

<ul>
<li><p>请选择 OSSEC HIDS 的安装路径 [/var/ossec]: <strong>/opt/ossec</strong></p>

<ul>
<li>OSSEC HIDS 将安装在  /opt/ossec .</li>
</ul></li>
</ul>

<p>3- 正在配置 OSSEC HIDS.</p>

<p>3.1- 请输入 OSSEC HIDS 服务器的IP地址或主机名: <strong>192.168.100.103</strong></p>

<ul>
<li><p>添加服务器IP  192.168.100.103</p>

<p>3.2- 您希望运行系统完整性检测模块吗? (y/n) [y]:</p></li>
<li><p>系统完整性检测模块将被部署.</p>

<p>3.3- 您希望运行 rootkit检测吗? (y/n) [y]:</p></li>
<li><p>rootkit检测将被部署.</p>

<p>3.4 - 您希望开启联动(active response)功能吗? (y/n) [y]:</p>

<p>3.5- 设置配置文件以分析一下日志:
-- /var/log/messages
-- /var/log/secure
-- /var/log/xferlog
-- /var/log/maillog
-- /var/log/httpd/error_log (apache log)
-- /var/log/httpd/access_log (apache log)</p>

<p>-如果你希望监控其他文件, 只需要在配置文件ossec.conf中
添加新的一项.
任何关于配置的疑问您都可以在 http://www.ossec.net 找到答案.</p>

<p>--- 按 ENTER 以继续 ---</p></li>
</ul>

<p>5- 正在安装系统
 - 正在运行Makefile
INFO: Little endian set.</p>

<p>…………省略编译输出…………</p>

<ul>
<li>系统类型是  Redhat Linux.</li>
<li><p>修改启动脚本使 OSSEC HIDS 在系统启动时自动运行</p></li>
<li><p>已正确完成系统配置.</p></li>
<li><p>要启动 OSSEC HIDS:
            /opt/ossec/bin/ossec-control start</p></li>
<li><p>要停止 OSSEC HIDS:
            /opt/ossec/bin/ossec-control stop</p></li>
<li><p>要查看或修改系统配置,请编辑  /opt/ossec/etc/ossec.conf</p>

<p>感谢使用 OSSEC HIDS.
如果您有任何疑问,建议或您找到任何bug,
<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="668ec9d18fe6fc8ed9e185e6e60509081207051226091515030548080312">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> 或邮件列表 <a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="78170b0b1d1b5514110b0c38170b0b1d1b56161d0c">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> 联系我们.<br />
( http://www.ossec.net/en/mailing_lists.html ).</p>

<p>您可以在　http://www.ossec.net 获得更多信息</p>

<p>--- 请按　ENTER 结束安装 (下面可能有更多信息). ---</p></li>
<li><p>您必须首先将该代理添加到服务器端以使他们能够相互通信.
这样做了以后,您可以运行'manage_agents'工具导入
服务器端产生的认证密匙.
/opt/ossec/bin/manage_agents</p>

<p>详细信息请参考:
http://www.ossec.net/en/manual.html#ma</p></li>
</ul>

<h2>配置OSSEC客户端</h2>

<hr />

<p>其实配置ossec客户端就是把刚才由服务端生成的key，在客户端中导入，执行如下命令
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="3c4e5353487c534f4f595f115d5b595248">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ossec-hids-2.7]# /opt/ossec/bin/manage_agents</p>

<pre><code>****************************************
* OSSEC HIDS v2.7 Agent manager.     *
* The following options are available: *
****************************************
   (I)mport key from the server (I).
   (Q)uit.
</code></pre>

<p>Choose your action: I or Q: <strong>I</strong></p>

<ul>
<li>Provide the Key generated by the server.</li>
<li>The best approach is to cut and paste it.
*** OBS: Do not include spaces or new lines.</li>
</ul>

<p>Paste it here (or '\q' to quit): <strong>MDAxIG9zc2VjLWFnZW50IDE5Mi4xNjguMTAwLjEwNCAzZWJmZWMzZmRlYzE2ODgzZmEyMzc0NWI5MWMyZDlmNmIyNDViZDMxNjBkZGRiM2FlMTk4NDA3ODNiNDFhYzYz</strong></p>

<p>Agent information:
   ID:001
   Name:ossec-agent
   IP Address:192.168.100.104</p>

<p>Confirm adding it?(y/n): y
Added.
** Press ENTER to return to the main menu.</p>

<p>最后启动客户端</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="e694898992a68995958385cb8781838892">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ossec-hids-2.7]# /opt/ossec/bin/ossec-control start
</code></pre>

<p>或者执行</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="1d6f7272695d726e6e787e307c7a787369">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ossec-hids-2.7]# /etc/init.d/ossec start
</code></pre>

<h2>安装web界面</h2>

<hr />

<p>上面我们安装了ossec的服务端，并且为ossec添加了一个客户端，非常简单的一个环境，环境是搭建好了，可是目前这个环境如果我们要分析ossec的报警信息就太麻烦了，所以我们安装第三方的 web界面用来显示报警信息。</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="9eecf1f1eadef1ededfbfdb3edfbece8fbec">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# wget https://github.com/ECSC/analogi/archive/master.zip
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="61130e0e15210e121204024c120413170413">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# unzip master
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="37455858437758444452541a445245415245">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# mv analogi-master/ /var/www/html/analogi
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="0f7d60607b4f607c7c6a6c227c6a7d796a7d">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# cd /var/www/html/
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="95e7fafae1d5fae6e6f0f6b8e6f0e7e3f0e7">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> html]# chown -R apache.apache analogi/
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="f684999982b69985859395db859384809384">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> html]# cd analogi/
[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="3e4c51514a7e514d4d5b5d134d5b4c485b4c">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> analogi]# cp db_ossec.php.new db_ossec.php
</code></pre>

<p>编辑db_ossec.php文件，修改MySQL的配置信息:</p>

<pre><code>define ('DB_USER_O', 'ossec');
define ('DB_PASSWORD_O', 'ossec');
define ('DB_HOST_O', '127.0.0.1');
define ('DB_NAME_O', 'ossec');
</code></pre>

<p>修改 apache 配置，增加虚拟目录，</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="c1b3aeaeb581aeb2b2a4a2ecb2a4b3b7a4b3">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# vim /etc/httpd/conf.d/analogi.conf
</code></pre>

<p>添加如下内容</p>

<pre><code>Alias /analogi /var/www/html/analogi
&lt;Directory /var/www/html/analogi&gt;
    Order deny,allow
    Deny from all
    Allow from 192.168.0.0/16
&lt;/Directory&gt;
</code></pre>

<p>然后重新启动Apache</p>

<pre><code>[<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="45372a2a31052a3636202668362037332037">[email&#160;protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> ~]# /etc/init.d/httpd restart
</code></pre>

<p>然后访问就可以了。</p>

<p><a href="http://192.168.100.103/analogi/">http://192.168.100.103/analogi/</a>
￼
<img src="http://static.wooyun.org/20140918/2014091813364183899.png" alt="enter image description here" /></p>

<h2>最后</h2>

<hr />

<p>上面是整个安装和配置步骤，要想让ossec发挥更大的作用，还需要针对实际的环境进行配置修改和规则的调整和编写。在以后的我们会更多关注OSSEC在实际应用中的经验。</p>      </p>
    
			</body>
		</html>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          